package com.egg.ylt.presenter.impl;

import com.egg.ylt.Utils.API;
import com.egg.ylt.pojo.HomePageEntity;
import com.egg.ylt.presenter.INewsPresenter;
import com.egg.ylt.view.INewsView;
import com.yonyou.framework.library.bean.ErrorBean;
import com.yonyou.framework.library.common.CommonUtils;
import com.yonyou.framework.library.mvp.impl.BasePresenter;
import com.yonyou.framework.library.net.ReqCallBack;
import com.yonyou.framework.library.net.RequestManager;

import java.util.HashMap;

/**
 * Created by sichaoqi on 2018/9/5.
 */

public class NewsPresenterImpl extends BasePresenter<INewsView> implements INewsPresenter {
    @Override
    public void getNewsData(String companyId, String pageNum, String pageSize, String messageClassify) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("companyId", companyId);
        hashMap.put("pageNum", pageNum);
        hashMap.put("pageSize", pageSize);
        hashMap.put("messageClassify", messageClassify);
        RequestManager.getInstance().requestPostByAsyn(API.GET_HOME_PAGE, hashMap, new ReqCallBack<HomePageEntity>() {

            @Override
            public void onReqSuccess(HomePageEntity result) {
                mView.getHomePage(result);
            }

            @Override
            public void onFailure(String result) {
//                mView.showError(result);
                CommonUtils.makeEventToast(mContext, result, false);
            }

            @Override
            public void onReqFailed(ErrorBean error) {
//                mView.showException(error.toString());
                CommonUtils.makeEventToast(mContext, error.getMsg(), false);
            }
        });
    }
}
